MATCH_WORKBENCH_BY_ID = "MATCH (w:WorkBench {benchId: $benchId}) RETURN w"
MATCH_WORKBENCH_TYPE_BY_ID = "MATCH (t:WorkBenchType {benchTypeId: $benchTypeId}) RETURN t"
MATCH_PROCESS_BY_ID = "MATCH (p:WorkBenchProcess {processId: $processId}) RETURN p"
MATCH_TOOL_PROOF_BY_ID = "MATCH (f:ToolProof {fpyeId: $fpyeId}) RETURN f"

GET_WORKBENCH_LIST = '''
MATCH (w:WorkBench)-[:WORKBENCH_IS_TYPE_OF]->(t:WorkBenchType)
{where}
RETURN w, t.benchTypeName AS benchTypeName
'''

CREATE_WORKBENCH = '''
MATCH (t:WorkBenchType {benchTypeId: $benchTypeId})
CREATE (w:WorkBench {
    benchId: $benchId,
    benchName: $benchName,
    status: $status,
    cycleTime: $cycleTime,
    createdBy: $createdBy,
    createdAt: $createdAt,
    updatedBy: $updatedBy,
    updatedAt: $updatedAt
})
CREATE (w)-[:WORKBENCH_IS_TYPE_OF]->(t)
RETURN w, t.benchTypeName AS benchTypeName
'''

UPDATE_WORKBENCH_TYPE = '''
MATCH (w:WorkBench {benchId: $benchId})
OPTIONAL MATCH (w)-[r:WORKBENCH_IS_TYPE_OF]->(:WorkBenchType)
DELETE r
WITH w
MATCH (t:WorkBenchType {benchTypeId: $benchTypeId})
CREATE (w)-[:WORKBENCH_IS_TYPE_OF]->(t)
SET {set_clauses}
RETURN w, t.benchTypeName AS benchTypeName
'''

UPDATE_WORKBENCH = '''
MATCH (w:WorkBench {benchId: $benchId})-[:WORKBENCH_IS_TYPE_OF]->(t:WorkBenchType)
SET {set_clauses}
RETURN w, t.benchTypeName AS benchTypeName
'''

DELETE_WORKBENCH = '''
MATCH (w:WorkBench {benchId: $benchId}) DETACH DELETE w
'''

GET_WORKBENCH_EQUIPMENTS = '''
MATCH (b:WorkBench {benchId: $benchId})-[:HAS_EQUIPMENT]->(e:Equipment)-[:EQUIPMENT_IS_TYPE_OF]->(t:EquipmentType)
RETURN e, t.equipmentTypeName AS equipmentTypeName, t.isMust AS isMust, t.isSingle AS isSingle
'''

CHECK_EQUIPMENT_EXISTS = '''
MATCH (e:Equipment {equipmentId: $equipmentId})-[:EQUIPMENT_IS_TYPE_OF]->(t:EquipmentType) RETURN e, t.equipmentTypeId AS equipmentTypeId, t.isSingle AS isSingle
'''

CHECK_EQUIPMENT_BOUND = '''
MATCH (b:WorkBench {benchId: $benchId})-[:HAS_EQUIPMENT]->(e:Equipment {equipmentId: $equipmentId}) RETURN e
'''

DELETE_SINGLE_TYPE_EQUIPMENT = '''
MATCH (b:WorkBench {benchId: $benchId})- [r:HAS_EQUIPMENT] -> (e:Equipment)-[:EQUIPMENT_IS_TYPE_OF]->(t:EquipmentType {equipmentTypeId: $equipmentTypeId})
DELETE r
'''

ADD_WORKBENCH_EQUIPMENT = '''
MATCH (b:WorkBench {benchId: $benchId}), (e:Equipment {equipmentId: $equipmentId}) CREATE (b)-[:HAS_EQUIPMENT]->(e)
'''

# 传送方式相关
MATCH_TRANSPORT_BY_ID = "MATCH (m:MaterialTransport {materialTransportId: $materialTransportId}) RETURN m"
MATCH_WORKBENCH_TRANSPORT_REL = "MATCH (b:WorkBench {benchId: $benchId})-[:WORKBENCH_TRANSPORT]->(m:MaterialTransport {materialTransportId: $materialTransportId}) RETURN m"
CHECK_WORKBENCH_TRANSPORT_BOUND = "MATCH (b:WorkBench {benchId: $benchId})-[:WORKBENCH_TRANSPORT]->(m:MaterialTransport {materialTransportId: $materialTransportId}) RETURN m"
CREATE_WORKBENCH_TRANSPORT_REL = "MATCH (b:WorkBench {benchId: $benchId}), (m:MaterialTransport {materialTransportId: $materialTransportId}) CREATE (b)-[:WORKBENCH_TRANSPORT]->(m)"
DELETE_WORKBENCH_TRANSPORT_REL = "MATCH (b:WorkBench {benchId: $benchId})-[r:WORKBENCH_TRANSPORT]->(m:MaterialTransport {materialTransportId: $materialTransportId}) DELETE r"

# 工序步骤相关
MATCH_PROCESS_STEP_BY_ID = "MATCH (s:WorkBenchProcessStep {stepId: $stepId}) RETURN s"
MATCH_WORKBENCH_PROCESS_STEP_REL = "MATCH (b:WorkBench {benchId: $benchId})-[:WORKBENCH_HAS_OPERATION]->(s:WorkBenchProcessStep {stepId: $stepId}) RETURN s"
CHECK_WORKBENCH_PROCESS_STEP_BOUND = "MATCH (b:WorkBench {benchId: $benchId})-[:WORKBENCH_HAS_OPERATION]->(s:WorkBenchProcessStep {stepId: $stepId}) RETURN s"
CREATE_WORKBENCH_PROCESS_STEP_REL = "MATCH (b:WorkBench {benchId: $benchId}), (s:WorkBenchProcessStep {stepId: $stepId}) CREATE (b)-[:WORKBENCH_HAS_OPERATION {actualTime: $actualTime}]->(s)"
UPDATE_WORKBENCH_PROCESS_STEP_REL = "MATCH (b:WorkBench {benchId: $benchId})-[r:WORKBENCH_HAS_OPERATION]->(s:WorkBenchProcessStep {stepId: $stepId}) SET r.actualTime = $actualTime"
DELETE_WORKBENCH_PROCESS_STEP_REL = "MATCH (b:WorkBench {benchId: $benchId})-[r:WORKBENCH_HAS_OPERATION]->(s:WorkBenchProcessStep {stepId: $stepId}) DELETE r"

# ToolProof相关
MATCH_WORKBENCH_TYPE_TOOL_PROOF_REL = "MATCH (t:WorkBenchType {benchTypeId: $benchTypeId})-[:WORKBENCH_TYPE_HAS_TOOL_PROOF]->(f:ToolProof {fpyeId: $fpyeId}) RETURN f"
CREATE_WORKBENCH_TYPE_TOOL_PROOF_REL = "MATCH (t:WorkBenchType {benchTypeId: $benchTypeId}), (f:ToolProof {fpyeId: $fpyeId}) CREATE (t)-[:WORKBENCH_TYPE_HAS_TOOL_PROOF]->(f)"
DELETE_WORKBENCH_TYPE_TOOL_PROOF_REL = "MATCH (t:WorkBenchType {benchTypeId: $benchTypeId})-[r:WORKBENCH_TYPE_HAS_TOOL_PROOF]->(f:ToolProof {fpyeId: $fpyeId}) DELETE r"

# 可继续补充workbench相关Cypher语句 